<?php
try {
    $dbh = new PDO('mysql:dbname=testbookstore;host=localhost', 'root', 'root');
} catch (PDOException $e) {
    echo '数据库连接失败：' . $e->getMessage();
    exit;
}

$query = "INSERT INTO contactInfo (name, address, phone) VALUES (:name, :address, :phone)";
$stmt = $dbh->prepare($query);

// 使用关联数组传递参数
$stmt->execute(array(":name" => "赵某某", ":address" => "海淀区", ":phone" => "15801688348"));

// bindParam方法绑定参数
$name = "赵某某1";
$address = "海淀区中关村1";
$phone = "158016883482";
$stmt->bindParam(":name", $name);
$stmt->bindParam(":address", $address);
$stmt->bindParam(":phone", $phone);
$stmt->execute();

?>

